using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ARViewMap : EntityTypeConfiguration<ARView>
    {
        public ARViewMap()
        {
            // Primary Key
            this.HasKey(t => new { t.CURRENCY, t.UNAPPLAMT, t.UNAPPLAMTA, t.UNAPPLAMTD });

            // Properties
            this.Property(t => t.ID)
                .HasMaxLength(6);

            this.Property(t => t.TYPE)
                .IsFixedLength()
                .HasMaxLength(2);

            this.Property(t => t.INVNO)
                .HasMaxLength(8);

            this.Property(t => t.CURRENCY)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.ENTITY)
                .HasMaxLength(4);

            this.Property(t => t.batch)
                .HasMaxLength(8);

            this.Property(t => t.DESC)
                .HasMaxLength(40);

            this.Property(t => t.REFERENCE)
                .HasMaxLength(6);

            this.Property(t => t.UNAPPLAMT)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.UNAPPLAMTA)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.UNAPPLAMTD)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.RV)
                .HasMaxLength(6);

            // Table & Column Mappings
            this.ToTable("ARView");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.TYPE).HasColumnName("TYPE");
            this.Property(t => t.INVNO).HasColumnName("INVNO");
            this.Property(t => t.DATE).HasColumnName("DATE");
            this.Property(t => t.POSTED).HasColumnName("POSTED");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.ENTITY).HasColumnName("ENTITY");
            this.Property(t => t.batch).HasColumnName("batch");
            this.Property(t => t.DESC).HasColumnName("DESC");
            this.Property(t => t.REFERENCE).HasColumnName("REFERENCE");
            this.Property(t => t.ARID).HasColumnName("ARID");
            this.Property(t => t.BAL).HasColumnName("BAL");
            this.Property(t => t.BALDOL).HasColumnName("BALDOL");
            this.Property(t => t.BALPAT).HasColumnName("BALPAT");
            this.Property(t => t.AMTpat).HasColumnName("AMTpat");
            this.Property(t => t.AMT).HasColumnName("AMT");
            this.Property(t => t.AMTDOL).HasColumnName("AMTDOL");
            this.Property(t => t.UNAPPLAMT).HasColumnName("UNAPPLAMT");
            this.Property(t => t.UNAPPLAMTA).HasColumnName("UNAPPLAMTA");
            this.Property(t => t.UNAPPLAMTD).HasColumnName("UNAPPLAMTD");
            this.Property(t => t.PAYERTYPE).HasColumnName("PAYERTYPE");
            this.Property(t => t.REF).HasColumnName("REF");
            this.Property(t => t.RV).HasColumnName("RV");
            this.Property(t => t.DUEDATE).HasColumnName("DUEDATE");
        }
    }
}
